package com.sckj.springbootdome.dao;

import com.sckj.springbootdome.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 数据访问
 */
@Mapper
public interface UserMapper {
    //查询全部
    @Select("select * from user")
    List<User> findAll();

    //新增数据
    @Insert("insert into user(username,password,fullname,mobile) values (#{username},#{password},#{fullname},#{mobile})")
    public int save(User user);

    //删除数据
    @Delete("delete from user where id= #{id}")
    public int delete(int id);

    //根据id查找
    @Select("select * from user where id= #{id}")
    public User get(int id);

    //更新数据
    @Update("update user set username=#{username},password=#{password},fullname=#{fullname},mobile=#{mobile} where id=#{id} ")
    public int update(User user);

}
